<?php
/**
 * Created by PhpStorm.
 * User: peter
 * Date: 2018/10/19
 * Time: 下午3:20
 */

namespace app\activity\controller;


use think\Request;

class Pay extends Auth
{
    /**
     * @purpose APP支付获取支付凭证
     * @param Request $request
     * @return array
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function appPayVoucher (Request $request)
    {
        $order_no       = $request->get('order_no');
        $pay_type       = $request->get('pay_type');
        return \app\activity\logic\Pay::appPayVoucher($order_no, $pay_type, self::$uid);
    }
    /**
     * @purpose 获取微信支付凭证
     * @param Request $request
     * @return array
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function voucher (Request $request)
    {
        $order_no       = $request->get('order_no');
        $pay_method       = $request->get('pay_method');
        return \app\activity\logic\Pay::voucher($order_no, self::$uid, $pay_method);
    }

    /**
     * @purpose 微信支付同步回调
     * @param Request $request
     * @return array
     * @throws \EasyWeChat\Kernel\Exceptions\HttpException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \Psr\SimpleCache\InvalidArgumentException
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function paySync(Request $request)
    {
        $order_no       = $request->get('order_no');
        return \app\activity\logic\PayNotify::paySync($order_no);
    }

    /**
     * @purpose APP支付同步回调
     * @param Request $request
     * @return array
     * @throws \EasyWeChat\Kernel\Exceptions\HttpException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \Psr\SimpleCache\InvalidArgumentException
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function appPaySync(Request $request)
    {
        $order_no       = $request->get('order_no');
        $pay_type       = $request->get('pay_type');
        return \app\activity\logic\PayNotify::appPaySync($order_no, $pay_type, self::$uid);
    }
}